//cancel order
function cancel(order_num){
	if(confirm("确认取消订单吗？")){
		$.ajax({
			type:"post",
			url:"/backend/action/ajax_r.jsp",
			data:{flag:"gift_cancelorder",enumNo:"106013",order_num:order_num},
			success:function(result){
				if($.trim(result)=="1"){
					//window.location.reload();
					var ifid;
					if (typeof(parent.tab) != 'undefined') {
						ifid = parent.tab.getSelectedTabItemID();
						if (typeof(parent.document.getElementById(ifid).contentWindow.grid) != 'undefined') {
							parent.document.getElementById(ifid).contentWindow.grid.loadData();
						}
					}
				}
			}
		});
	}
}

//refund 
function refund(order_num){
	if(confirm("确认退款吗？")){
		$.ajax({
			type:"post",
			url:"/backend/action/ajax_r.jsp",
			data:{flag:"gift_refundorder",enumNo:"106013",order_num:order_num},
			success:function(result){
				if($.trim(result)=="1"){
					//window.location.reload();
					var ifid;
					if (typeof(parent.tab) != 'undefined') {
						ifid = parent.tab.getSelectedTabItemID();
						if (typeof(parent.document.getElementById(ifid).contentWindow.grid) != 'undefined') {
							parent.document.getElementById(ifid).contentWindow.grid.loadData();
						}
					}
				}
			}
		});
	}
}

//pay order
function pay(order_num){
	window.open("/purchase/trade/ycpay.jsp?OrderNumber="+order_num);
}

//assort order
function assort(order_num){
	$.ajax({
		type:"post",
		url:"/backend/action/ajax_r.jsp",
		data:{flag:"gift_assortorder",enumNo:"106013",order_num:order_num},
		success:function(result){
			if($.trim(result)=="1"){
				//window.location.reload();
				var ifid;
				if (typeof(parent.tab) != 'undefined') {
					ifid = parent.tab.getSelectedTabItemID();
					if (typeof(parent.document.getElementById(ifid).contentWindow.grid) != 'undefined') {
						parent.document.getElementById(ifid).contentWindow.grid.loadData();
					}
				}
			}
		}
	});
}

//finish order
function finish(order_num){
	$.ajax({
		type:"post",
		url:"/backend/action/ajax_r.jsp",
		data:{flag:"gift_finishorder",enumNo:"106013",order_num:order_num},
		success:function(result){
			if($.trim(result)=="1"){
				//window.location.reload();
				var ifid;
				if (typeof(parent.tab) != 'undefined') {
					ifid = parent.tab.getSelectedTabItemID();
					if (typeof(parent.document.getElementById(ifid).contentWindow.grid) != 'undefined') {
						parent.document.getElementById(ifid).contentWindow.grid.loadData();
					}
				}
			}
		}
	});
}

//ship order
function ship(order_num){
	$.ajax({
		async:false,
		type:"post",
		url:"/backend/action/ajax_r.jsp",
		data:{flag:"gift_shiporder",enumNo:"106013",order_num:order_num},
		success:function(result){
			if($.trim(result)=="1"){
				//window.location.reload();
				var ifid;
				if (typeof(parent.tab) != 'undefined') {
					ifid = parent.tab.getSelectedTabItemID();
					if (typeof(parent.document.getElementById(ifid).contentWindow.grid) != 'undefined') {
						parent.document.getElementById(ifid).contentWindow.grid.loadData();
					}
				}
			}
		}
	});
}

//send sms
function sendsms(order_num){
	$.ajax({
		type:"post",
		url:"/backend/action/ajax_r.jsp",
		data:{flag:"gift_shipsmsalert",enumNo:"106013",order_num:order_num},
		success:function(result){
			if($.trim(result)=="2"){
				alert("手机号码为空！");
			}else if($.trim(result)=="0"){
				alert("发送失败，系统异常，请稍后重试");
			}else if($.trim(result)=="-1"){
				alert("内容为空");
			}else if($.trim(result)=="-2"){
				alert("手机号位数不正确");
			}else if($.trim(result)=="-3"){
				alert("发送内容超过最大长度");
			}else if($.trim(result)=="-4"){
				alert("短信接口异常");
			}else if($.trim(result)=="-5"){
				alert("手机号码过多");
			}else if($.trim(result)=="1"){
				alert("短信已发送");
			}
			window.location.reload();
		}
	});
	//toolbarAdd({width:800,height:200,folderName:'yecheng_common_user',fileName:'yecheng_common_sms',params:{order_num:order_num},title:'编辑短信'});
}